<?php
class pk_profile extends BaseModel implements Retrievable {

	var $user;
	var $country;
	var $contact;
	var $website;
	var $state;
	var $city;
	var $name;
	
    public function pk_profile($values) {
        parent::__construct($values);
    }

    public function validate() {
        $errors = Array();
		return (count($errors) === 0 ? true : $errors);
    }

    public static function get($id, $primaryKey='id') {
        return parent::get($id, __CLASS__, $primaryKey);
    }
    
    public static function getAll($searchArray=Array(), $sortArray=Array(), $limit=0) {
        return parent::getAll($searchArray, $sortArray, __CLASS__, $limit);
    }
    
    public static function search($keyword) {    	
    	$keywords = addslashes(str_replace(' ', ' +', $keyword)) . '*';
    	$query = "SELECT p.*, MATCH(p.name) AGAINST('{$keywords}' IN BOOLEAN MODE) as relevance 
					FROM pk_profile p  
					WHERE MATCH(p.name) AGAINST('{$keywords}' IN BOOLEAN MODE) 
					HAVING relevance > 0.0 ORDER BY relevance DESC";
    	return BaseModel::getByQuery($query, __CLASS__);
    }
    
}
?>